package com.example.springboot.controller;

import com.example.springboot.document.User;
import com.example.springboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: MybatisController
 * @Author wenlinyu
 * @Date: 2020/12/15 17:04
 * @Version 1.0
 */
@RestController
public class MybatisController {

    @Autowired
    private UserMapper userMapper;

    @GetMapping("/save")
    public String save() {
        int row1 = userMapper.insert(new User("u1", "p1"));
        return "插入条数：" + row1;
    }

    public List<User> find() {
        List<User> u1 = userMapper.findByUsername("u1");
        return u1;
    }
}
